<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .form{
            width: 250px;
            height: 200px;
            background-color: green;
            margin: 0 auto;
            padding: 50px;
            text-align: center;
        }
        .w-150{
            width: 200px;
            margin-bottom: 10px;
        }

        .h-30{
            height: 30px;
        }

        .button {
            background-color: #4CAF50; /* Green */
            border: none;
            color: white;
            padding: 10px;
            width: 230px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin-bottom: 10px;
        }

    </style>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>

<div class="form">
    <div>
        邮箱:  <input type="email" class="w-150 h-30" id="email">
    </div>
    <div>
        密码:  <input type="password" class="w-150 h-30" id="password"/>
    </div>

    <button class="button" id="login">登录</button>

    <div id="register"><a>立即注册</a></div>
</div>


</body>
<script>
    $(document).ready(function(){
        $("#login").click(function(){
            var email = $("#email").val();
            var password = $("#password").val();
            if(!email){
                alert("请输入邮箱");
                return;
            }

            if(!password){
                alert("请输入密码");
                return;
            }
            $.ajax(
                {
                    url:"/api/user/login/"+email+"/"+password,
                    type: "POST",
                    success:function(result){
                        window.location.href = "welcome.html";
                    },
                    error:function(err){
                        alert(err.responseText);
                    }
                });
        });

        $("#register").click(function(){
            window.location.href = "register.html";
        });

    });
</script>
</html>